import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * Created by Administrator on 2016/3/17.
 */
public class KafkaConfig {

    public final static String ZOOKEEPER_CONNECT;
    public static final String ZOOKEEPER_SESSION_TIMEOUT;
    public static final String ZOOKEEPER_SYNC_TIME;
    public final static String AUTO_COMMIT_INTERVAL_MS;

    public final static String METADATA_BROKER_LIST;
    public final static String GROUP_ID;
    public final static String SERIALIZER_CLASS;
    public final static String REQUEST_REQUIRED_ACKS;

    static {
        ClassLoader classLoader = KafkaConfig.class.getClassLoader();
        InputStream in = classLoader.getResourceAsStream("kafkaconfig.properties");
        Properties properties = new Properties();
        try {
            properties.load(in);
        } catch (IOException e) {
            e.printStackTrace();
        }

        ZOOKEEPER_CONNECT = properties.getProperty("zookeeper.connect", "localhost:2181");
        ZOOKEEPER_SESSION_TIMEOUT = properties.getProperty("zookeeper.session.timeout.ms", "40000");
        ZOOKEEPER_SYNC_TIME = properties.getProperty("zookeeper.sync.time.ms", "200");
        AUTO_COMMIT_INTERVAL_MS = properties.getProperty("auto.commit.interval.ms", "1000");

        METADATA_BROKER_LIST = properties.getProperty("metadata.broker.list", "localhost:9092");
        GROUP_ID = properties.getProperty("group.id", "consumer-test-group");
        SERIALIZER_CLASS = properties.getProperty("serializer.class", "kafka.serializer.StringEncoder");
        REQUEST_REQUIRED_ACKS = properties.getProperty("request.required.acks", "0");
    }

}
